package me.wpf;

import me.wpf.dao.Esdao;
import me.wpf.utils.DateUtils;
import org.elasticsearch.client.RestHighLevelClient;

import java.util.*;

/**
 * Hello world,
 */
public class Boot {
    public static void main(String[] args) {
        RestHighLevelClient restHighLevelClient = Esdao.getRestHighLevelClient();
        String str = "美洲虎,是,一种,濒临灭绝的动物,据说,目前,世界上仅存不足20只,其中有一只现在就生活在秘鲁的国家动物园里为了保护这只美洲虎,秘鲁人在,动物园里单独为它圈出一,块地来,且圈地中,有成群的牛、羊、鹿供老虎事用参观过虎园的人都惊叹地称这里是,虎的天堂,然而,令人感到非常奇怪的是,没有人看见这只老虎去捕捉牛羊,唯一能见到的就是它躺在它的虎房里重复着吃与睡的情景," +
                "Some people thought that the jaguar felt toolonely, so they collected money and rented a female tiger to accompany it, Nonetheless, it did not make too much sense, The jaguar just sometimes went out of its house with its ,girlfriend, and stayed in the sun for a while before it came back to its house again," +
                "一些人认为肯定是美洲虎太孤独了,于是就集资从国外租来一只雌虎陪它生活然而此举并未带来多大改观,那只老虎只是偶尔陪伴外来的,女友,走,出虎房,到,,阳光下站一会儿,不久就又回到它的,卧室," +
                ",It is normal for the jaguar to be lazy in this environment, Tiger is the king of forest but you simply put some small animals a,round him, That is why t,he jaguar shows no interest in going out, Why don 't you put two wolves or at least a jackal around him, A visitor proposed," +
                ",在这种环境下,美洲虎不懒散才怪呢,虎是林中之王,你们在它周围放这么一群小动物,它怎么可能有兴趣走出来,为什么你们不放上两只狼呢,即使不放狼,至少也得放一只翁狗吧,一位来此参,观的市民建议道," +
                "Others all agreed with him, and put ,five panthers into ,the jaguar's territory, Since then, the jaguar did not go back to its house any more, It either stands on top of the hill roaring or goes down from the hill strolling without sleeping all day long, It did not eat the meat provided by the zoo staff and has totally got back to its nature," +
                "其他人都觉得他说得很,有道理,就把5只美洲豹技进了虎园结果就是,自那以后,美洲虎就再没回过虎房它不是站在山顶长啸,就是从山上下来,在草地上游荡;它不再整日睡觉,也不再吃动物园的,管理员送来的肉,它恢复了虎的本性," +
                "Actually, this principle does not only apply to animals, but also apply to human beings, Here is another story, There was a rich man who was select,ing a husband for his only child among a multitude of pursuers, The man led all the pursuers to a river and pointed to the crocodiles, saying, ,Anyone who can swim across the river safe and sound will marry my daughter, Those pursuers looked at each other and no one dare take the initiative, At that moment, a man plunged into the river bravely and swam at a staggering speed to the other side, AII the people applauded for his courage with great sense of admiration, Nevertheless, the man, after landing on the bank, shouted angrily, ,Who pushed me into the river just now," +
                "其实,不,只是动物,人,也如此有这,样,一则,故事:一个富人为其独生女儿选婿,而求婚者众多于是这个富人将所有的求婚者带到一条向边,指着凋里的鳝鱼说道,如果谁能够安全地游到对岸,我就会把我的女儿嫁给他,这些追求者们你看看我,我看看你,没有人敢跳进问里正在这时,突然有一个男子,扑通,一声很勇敢地跳了下去,然后以超乎寻常的速度游到对岸所有的人对这名勇气十足的男子投以钦佩和羡慕的目光没想到,这个男子上岸后,生气地大声问道,刚才是谁把我推下河去的," +
                "Maybe the man, after thinking of the,, whole process and the, good consequence he is going to obtain, will feel obliged to the one who pushed him into the rive,r, It is fairly common that disadvantages will turn into advantages and misfortunes into fortunes, But many of us cannot manage to realize the significance of our ,rivals, to our success, Generally speaking, many people will see the one who ,pushes him into the river, as an opponent, However, if you think in a deeper sense, you will realize that it is also a blessing and opportunity to have someone like that, It is the one who ,pushes you into the river, who makes you feel the sense of crisis and stimulates your ambition and desire to strive, You will resolve to eliminate all difficulties and progress to another stage of your life," +
                "或许那位男子,在回头想想整,件事情的经,,过后,会有很大,的收获,也会很感谢,那位推他下河的人把不利变有利,将坏事变好事,这样的例子,,在现实屡见不鲜但很少有人能,认识到造成这个,结果的那个,对手,在此之中所起的重要作用一般讲来,多数人都会把推他,下河,的人视做敌人,不过你只要往深处想想就会发现,这未尝不是一种福分、一种机遇有这样一个,推你下河,的人的存在,会促使你产生危机感,从而激发你更加旺盛的精神和斗志,你会下定决心排除一切艰难险阻,在前行路上跃上一个更高的舞台,";
        List<String> strings = Arrays.asList(str.split(","));
        int size = strings.size();
        Long start = System.currentTimeMillis();
        System.out.println("start:" + DateUtils.getCurDate(DateUtils.DATE_TIME_FORMAT));

        for (int j = 1; j <= 10000; j++) {
            List<Map<String, Object>> list = new ArrayList<>();
            for (int t = 0; t < 5; t++) {
                Map<String, Object> map = new HashMap<>();
                for (int i = 0; i < 100; i++) {
                    map.put("obj_id", "obj" + j + t + i);
                    Object value = null;
                    if (i % 5 == 0) {
                        value = new Double(Math.random() * 100) + 1;
                    } else {
                        value = strings.get(new Random().nextInt(size));
                    }
                    map.put("c" + i, value);
                }
                list.add(map);
            }
            boolean b = Esdao.insertBatchV1(list, restHighLevelClient);
            System.out.println(String.format("%d=%s, 总:%d", j, String.valueOf(b), 5 * j));
        }
        System.out.println("end:" + DateUtils.getCurDate(DateUtils.DATE_TIME_FORMAT));
    }


}
